/***********************************************************
For Text Drawing purposes.
1. Use setup(D3DDevice); before anything else.
2. Use any of the type setting functions to format the text
3. Use draw(); to draw :)
***********************************************************/

#pragma once
#include "framework.h"

namespace poly
{

class Text
{
private:
	/**
	 * Font interface for D3D9.
	 */
	Font			fontInterface;

	/**
	 * Font description for D3D9.
	 */
	FontDescription	fontD;

	/**
	 * Current device.
	 */
	D3DDevice		device_ptr;

	/**
	 * Box of the text.
	 */
	RECT			textQuad;

	/**
	 * Text itself.
	 */
	text*			textString;

	/**
	 * Color of the text.
	 */
	float3			color;

	/**
	 * True if text properties have been recently updated.
	 */
	bool			changed;

	/**
	 * True if fontD has a value.
	 */
	bool			fontInterfaceCreated;
public:
	Text();
	~Text();

	/**
	 * Call this prior to any function call.
	 */
	void setup(D3DDevice);

	/**
	 * Default 40.
	 * @param Width.
	 */
	void setWidth(int);
	/**
	 * Default 80.
	 * @param Height.
	 */
	void setHeight(int);
	/**
	 * Default 400.
	 * @param Weight.
	 */
	void setWeight(int);
	/**
	 * Default false.
	 * @param True if Italic.
	 */
	void setItalic(bool);
	/**
	 * Default Arial.
	 * @param Name of face.
	 */
	void setFace(char*);
	/**
	 * @param Position on screen. (0,0) is top left.
	 */
	void setPosition(float2);
	/**
	 * @param Output text.
	 */
	void setText(char*);

	/**
	 * @param Color. 0~255 (r,g,b)
	 */
	void setColor(float3);

	/**
	 * Flushes text onto the screen.
	 */
	void draw();

	/**
	 * Call onLostGraphics.
	 */
	void onLost();

	/**
	 * Call onResetGraphics.
	 */
	void onReset();
};

} //end of poly